﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Infrastructure.Domain.SeedWork;
using Infrastructure.Domain.SeedWork.Core.Specification;

namespace Infrastructure.DAL.SeedWork.Extension
{
    public interface IBaseDomainService
    {
        TEntity Get<TEntity>(long id) where TEntity : Entity;

        void Add<TEntity>(TEntity entity) where TEntity : Entity;

        void Modify<TEntity>(TEntity entity) where TEntity : Entity;

        void Remove<TEntity>(TEntity entity) where TEntity : Entity;

        void Remove<TEntity>(long id) where TEntity : Entity;


        TEntity GetLast<TEntity>(ISpecification<TEntity> specification) where TEntity : Entity;

        TEntity Single<TEntity>(ISpecification<TEntity> specification) where TEntity : Entity;

        IEnumerable<TEntity> GetAll<TEntity>() where TEntity : Entity;

        IEnumerable<TEntity> GetAllMatching<TEntity>(ISpecification<TEntity> specification) where TEntity : Entity;


        IEnumerable<TEntity> GetPaged<TEntity, TProperty>(int pageIndex, int pageCount,
            Expression<Func<TEntity, TProperty>> orderByExpression,
            bool @ascending,
            ISpecification<TEntity> specification = null)
            where TEntity : Entity;

        IEnumerable<TEntity> GetFiltered<TEntity>(Expression<Func<TEntity, bool>> filter) where TEntity : Entity;

        void Merge<TEntity>(TEntity persisted, TEntity current) where TEntity : Entity;
    }
}